﻿<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" CodeBehind="ChangeCity.aspx.cs"
    Inherits="Card.Web.ChangeCity" %>

<%@ Import Namespace="BAF.Entity" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Src="Controls/TopUserInfo.ascx" TagPrefix="uc1" TagName="UserInfo" %>
<%@ Register Src="Controls/Footer.ascx" TagName="Footer" TagPrefix="uc1" %>
<%@ Register Src="Controls/Logo.ascx" TagPrefix="uc1" TagName="Logo" %>
<%@ Import Namespace="Card" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>名片设计|在线印刷品-切换城市_<%=SiteName %></title>
    <link href="css/layout.css" type="text/css" rel="Stylesheet" />
    <link href="css/ui-lightness/jquery-ui-1.9.2.custom.min.css" rel="Stylesheet" />

    <script src="JavaScript/jquery-1.8.3.min.js" type="text/javascript"></script>

    <script src="JavaScript/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>

    <script src="JavaScript/common.js" type="text/javascript"></script>

    <script type="text/javascript">
        function site_not_open() {
            $("#openCity").dialog({ modal: true });
        }

        function close_dialog() {
            $('#openCity').dialog('close');
        }
        
        function showsite(id){
            $(".sitefocus").each(function(){
                $(this).removeClass("sitefocus");
            });
            $("#a"+id).addClass("sitefocus");            
            $(".sitecontainer").each(function(){
                if($(this).attr("id") != id){
                    $("#c"+$(this).attr("id")).hide();
                    $(this).hide();
                }else{
                    $("#c"+id).show();
                    $(this).show();
                }
            });
        }
    </script>

    <style type="text/css">
        #clist { text-align: center; font-size: 14px; font-family: Arial, "宋体" , sans-serif; line-height: 200%; margin: 0 auto; padding: 20px 0px 20px 0px; clear: both; overflow: hidden; zoom: 1; }
        #clist a { font-size: 13px; white-space: nowrap; }
        #clist td { border-bottom: 1px dashed #FED08D; padding: 5px; }
        #clist .header { vertical-align: top; width: 70px; padding-left: 20px; padding-right: 20px; padding-top: 5px; font-family: Arial, Helvetica, sans-serif; font-size: 16px; clear: both; font-weight: bold; }
        #clist .city a { float: left; text-align: left; margin-right: 14px; list-style: none; }
        #clist .alter { background-color: #E4F3FE; }
        .link { color: Blue; text-decoration: none; }
        #clist ul { list-style: none; }
        #clist ul li { float: left; margin-right: 14px; }
        .sitecontainer { display: none; width: 800px; border: 2px solid #F60; background: white; padding: 5px; margin-top: -2px; z-index: -1; }
        .sitecontainer ul { list-style: none; }
        .sitecontainer ul li { float: left; }
        .sitefocus { display: none; }
    </style>
</head>
<body>
    <uc1:UserInfo runat="server"></uc1:UserInfo>
    <uc1:Logo EnableChangeCity="false" runat="server"></uc1:Logo>
    <div class="Nav" style="height: 5px;">
    </div>
    <div class="main solid_border">
        <div class="top_info clear-fix">
            <h2>
                切换城市</h2>
        </div>
        <table id="clist" style="width: 100%;">
            <% 
                Card.Web.IP.IPLocation location = Card.Web.IP.QQWryLocator.Query();
                bool selectedIp = string.IsNullOrEmpty(location.Country);
                List<Card.Entity.Area> lstProvince = Card.Common.AreaCache.GetProvinceArea();
                int i = 1;
                foreach (Card.Entity.Area province in lstProvince)
                {
                    List<Card.Entity.Area> lstCity = Card.Common.AreaCache.GetChildrenArea(province.ID);
                    if (lstCity != null && lstCity.Count > 0)
                    {
                        i++;
            %>
            <tr <%= (i%2==0)?"class='alter'":"" %>>
                <td valign="top" align="right" class="header">
                    <%=province.Name %>
                </td>
                <td class="city">
                    <%
                        foreach (Card.Entity.Area city in lstCity)
                        {
                            List<Card.Entity.Area> lstSite = Card.Common.AreaCache.GetChildrenArea(city.ID);
                            Card.Entity.Area openSite = lstSite.Find(e => string.Compare(e.IsActive, CONST.YES_NO.YES) == 0);
                            string cityStyle = string.Empty;
                            if (openSite != null)
                            {
                                cityStyle = "style='color:red;'";
                            }
                    %>
                    <dl>
                        <dt><a class="link" <%=cityStyle %> id="ac<%=city.ID %>" href="javascript:void(0);showsite('c<%=city.ID %>');">
                            <%=city.Name%></a></dt><dd>
                                <div id="cc<%=city.ID %>" style="display: none; clear: both; color: Blue;" />
                                <div class="sitecontainer clear-fix" id="c<%=city.ID %>">
                                    <span style="float: left; margin-right: 10px;"><b>
                                        <%=city.Name%></b></span><br />
                                    <ul>
                                        <%
                                            foreach (Card.Entity.Area area in lstSite)
                                            {
                                                if (string.Compare(area.IsActive, CONST.YES_NO.YES) == 0)
                                                {
                                        %>
                                        <li><a href='<%= area.SiteUrl %>' style="color: Red;">
                                            <%=area.Name%></a></li>
                                        <%          
                                            }
                                                else
                                                {
                                        %>
                                        <li><a href="javascript:void(0);site_not_open();">
                                            <%=area.Name%></a></li>
                                        <%
                                            }
                                            }
                                        %>
                                    </ul>
                                </div>
                            </dd>
                    </dl>
                    <% 
                        if (!selectedIp && (location.Country.IndexOf(city.Name) >= 0 || location.Local.IndexOf(city.Name) >= 0))
                        {
                            selectedIp = true;
                            %>
                            <script type="text/javascript">
                                showsite('c<%=city.ID %>');
                            </script>
                            <%
                        }
                        }
                    %>
                </td>
            </tr>
            <%
                }
                } %>
        </table>
    </div>
    <div id="openCity" style="display: none; text-align: center;">
        <p>
            该城市站还没有开通！<a href="/help.aspx?t=join" class="link" style="color: Blue;">
                去开通 >></a></p>
        <p>
            名称为<font color="red">红色</font>的城市开通的有分站！</p>
        <span><a href="javascript:void(0);" onclick="close_dialog();" class="link" style="color: Blue;">返回继续选择>></a></span>
    </div>
    <uc1:Footer ID="footer" runat="server" />
</body>
</html>
